#ifndef DICE_H
#define DICE_H

#include "dtwenty_global.h"

#include <collection.h>
#include <item.h>

#include <QMetaType>


typedef Item Die;


class DTWENTYSHARED_EXPORT Dice : public Collection
{
    Q_OBJECT

public:

    enum Field
    {
        Field_FIRST = 0,

        Field_NAME = Field_FIRST,
        Field_MIN,
        Field_MAX,

        // Field_BONUS,

        Field_LAST = Field_MAX
    };


    Q_INVOKABLE Dice(QObject *parent = 0) :
        Collection(QT_TR_NOOP("Dice"), parent)
    {
    }

    Dice(const Dice& other) :
        Collection(other)
    {
    }

    Q_INVOKABLE virtual void onInitialize()
    {
        setField(Field_NAME, QT_TR_NOOP("Name"), false);
        setField(Field_MIN, QT_TR_NOOP("Minimum"), false);
        setField(Field_MAX, QT_TR_NOOP("Maximum"), false);

        if (childItems().count()) return;

        Item* die = qobject_cast<Item*>(Dice::create("Item", this));
        die->setValue(Field_NAME, "d4");
        die->setValue(Field_MIN, 1);
        die->setValue(Field_MAX, 4);


        die = qobject_cast<Item*>(Dice::create("Item", this));
        die->setValue(Field_NAME, "d6");
        die->setValue(Field_MIN, 1);
        die->setValue(Field_MAX, 6);

        die = qobject_cast<Item*>(Dice::create("Item", this));
        die->setValue(Field_NAME, "d8");
        die->setValue(Field_MIN, 1);
        die->setValue(Field_MAX, 8);

        die = qobject_cast<Item*>(Dice::create("Item", this));
        die->setValue(Field_NAME, "d10");
        die->setValue(Field_MIN, 1);
        die->setValue(Field_MAX, 10);

        die = qobject_cast<Item*>(Dice::create("Item", this));
        die->setValue(Field_NAME, "d12");
        die->setValue(Field_MIN, 1);
        die->setValue(Field_MAX, 12);

        die = qobject_cast<Item*>(Dice::create("Item", this));
        die->setValue(Field_NAME, "d20");
        die->setValue(Field_MIN, 1);
        die->setValue(Field_MAX, 20);

    }




};

Q_DECLARE_METATYPE(Dice*)


#endif // DICE_H
